{% if dataset.paginator.num_pages > 1 %}
  <div class="pagination">
    <span class="step-links">
      {% if dataset.has_previous %}
        <a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{ dataset.previous_page_number }}{% if filename_search %}&filename={{filename_search}}{% endif %}">Previous</a>
      {% endif %}

      {% for pagenum in dataset.paginator.page_range %}
	<a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{pagenum}}{% if filename_search %}&filename={{filename_search}}{% endif %}">{{pagenum}}</a>
      {% endfor %}

      {% if dataset.has_next %}
        <a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{ dataset.next_page_number }}{% if filename_search %}&filename={{filename_search}}{% endif %}">Next</a>
      {% endif %}
      <br/>
      <span class="current">
        Page {{ dataset.number }} of {{ dataset.paginator.num_pages }}.
      </span>
    </span>
  </div>
  <br/>
{% endif %}

<div style="">
{# uploadify here #}

{% if has_write_permissions %}
  {% if not experiment.public %}
    {% if not immutable %}
      <a class="upload_files_link">Upload Files To Dataset</a>
      <div class="upload_files_container"></div>
      <input class="dataset_id" type="hidden" value="{{dataset_id}}">
    {% endif %}
  {% endif %}
{% endif %}

File path search: <input type="text" onKeyPress="return disableEnterKey(event)" class="filename_search" name="filename" value="{% if filename_search %}{{filename_search}}{% endif %}"> <em>(eg. enter 'test' to show the '/Frames/test/' directory)</em>
</div>
<br/>
Select: <a class="dataset_selector_all">[All]</a> / <a class="dataset_selector_none">[None]</a>
<br/><br/>
<script type="text/javascript">
  $("input[name$='show_datafile_search']").click(function() {
    if($(this).val() == "matches")
    {   
      $(".datafile").hide();
      $(".search_match_file").show();
    } 
    else
    {
      $(".datafile").show();
    }
  }); 
</script>
{% if highlighted_dataset_files %}
<form name="datafile_search_select_form" id="datafile_search_form" method="post" action="">
    <div><label><input type="radio" name="show_datafile_search" value="all" checked>Show all</label></div>  
    <div><label><input type="radio" name="show_datafile_search" value="matches">Search matches only</label></div>  
</form>
{% endif %}
{% for datafile in dataset.object_list %}
<li class="datafile {% if datafile.pk in highlighted_dataset_files %} search_match_file{% endif %}">
	<input type="checkbox" class="datafile_checkbox" name="datafile" value="{{datafile.id}}">

    {% if datafile.pk in highlighted_dataset_files %}
    <span style="background-color: #FFFF00">
    {% endif %}
    <a class="filelink" href="{{ datafile.get_download_url }}" target="_blank">{{ datafile.filename }}</a>
    {% if datafile.pk in highlight_dataset_files %}
    </span>
    {% endif %}
    {% if datafile.size %}({{ datafile.size|filesizeformat }}){% endif %}
	Metadata: {% if has_write_permissions %}{% if not experiment.public %}{% if not immutable %}<a href="{% url tardis.tardis_portal.views.add_datafile_par datafile.id %}"
	 class="jqModalDfA{{datafile.id}}">[Add]</a>{% endif %}{% endif %}{% endif %}
	<script type="text/javascript">
	$('#jqmAlertDfA{{datafile.id}}').die();
	$('#jqmAlertDfA{{datafile.id}}').jqm({
	  trigger: '.jqModalDfA{{datafile.id}}',
	  ajax: '@href',
	  target: '#jqmAlertContentdatafileA{{datafile.id}}',
	  overlay: 0
	  });
	</script>
	<div class="jqmAlert" id="jqmAlertDfA{{datafile.id}}">

		<div class="jqmAlertWindow">
		    <div class="jqmAlertTitle clearfix">
		    <h1>Add Parameters</h1><a href="#" class="jqmClose"><em>Close</em></a>
		  </div>

		  <div class="jqmAlertContent" id="jqmAlertContentdatafileA{{datafile.id}}">
		  <p>Please wait... <img src="/site_media/images/busy.gif" alt="loading" /></p>
		  </div>
		</div>
	</div>

	<a class="datafile_info_toggle" href="/ajax/parameters/{{ datafile.id}}">[Show]</a>
	{% block extra_links %}
	{% endblock extra_links %}
	<ul class="datafile_info">

	</ul>

</li>
{% endfor %}


{% if dataset.paginator.num_pages > 1 %}
<br/>
<div class="pagination">
  <span class="step-links">
    {% if dataset.has_previous %}
      <a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{ dataset.previous_page_number }}{% if filename_search %}&filename={{filename_search}}{% endif %}">Previous</a>
    {% endif %}

    {% for pagenum in dataset.paginator.page_range %}
      <a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{pagenum}}{% if filename_search %}&filename={{filename_search}}{% endif %}">{{pagenum}}</a>
    {% endfor %}

    {% if dataset.has_next %}
      <a class="pagelink" href="/ajax/datafile_list/{{dataset_id}}/?page={{ dataset.next_page_number }}{% if filename_search %}&filename={{filename_search}}{% endif %}">Next</a>
    {% endif %}
    <br/>
    <span class="current">
      Page {{ dataset.number }} of {{ dataset.paginator.num_pages }}.
    </span>
  </span>
</div>
{% endif %}
